<template>
    <div class='app'>
        <el-header>
            <div class='container'>
                <el-row>
                    <el-col :span='6' class='logo'>
                        <img src='/static/image/public/logo-header.png'>
                    </el-col>
                    <el-col :span='18' class='nav'>
                        <el-row>
                            <el-col :span='4' v-for='(item,key) in navs' :key='key'>
                                <div :class='item.name == sNav ? "active" : ""'
                                    @click='toUrl(item.url)'>{{item.name}}</div>
                            </el-col>
                        </el-row>
                    </el-col>
                </el-row>
            </div>
        </el-header>
        <el-main>
            <div class='container'>
                <router-view></router-view>
            </div>
        </el-main>
        <el-footer :height='"220px"'>
            <div class='container'>
                <el-row class='_box-link'>
                    <el-col :span='4' :offset='4'>关于我们</el-col>
                    <el-col :span='4'>联系我们</el-col>
                    <el-col :span='4'>服务协议</el-col>
                    <el-col :span='4'>家长监护</el-col>
                </el-row>
                <el-row>
                    <el-col :span='4' class='logo'>
                        <img src='/static/image/index/logo.png'>
                    </el-col>
                    <el-col :span='14' class='text'>
                        <p>抵制不良游戏，拒绝盗版游戏。注意自我保护，谨防受骗上当。适度游戏益脑，沉迷游戏伤身。</p>
                        <p>公司地址：重庆市江北区建新北路38号3幢31-1 电话：023-86062306</p>
                        <p>统一社会信用代码：91500105MA5URQ0284</p>
                        <p>网站备案/许可证号 : 渝ICP备17012945号-1</p>
                        <p>网络文化经营：渝网文[2018]0712-010号 <a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=50010502001410" target="_blank">渝公网安备 50010502001410号</a></p>
                    </el-col>
                    <el-col :span='6' class='qr-code'>
                        <img src='/static/image/index/qrcode.png'>
                        <img src='/static/image/index/qrcode.png'>
                    </el-col>
                </el-row>
                <br>
                <br>
            </div>
        </el-footer>
    </div>
</template>

<script>
import Common from '@/common/Common'
export default {
    name: 'App',
    data : function(){
        return {
            'navs' : [
                {
                    'name' : '首页',
                    'url' : '/'
                }, {
                    'name' : '资讯',
                    'url' : '/news'
                }, {
                    'name' : '下载',
                    'url' : '/download'
                }, {
                    'name' : '资料库',
                    'url' : '/data'
                }, {
                    'name' : '客服',
                    'url' : ''
                }
            ],
            'sNav' : '首页'
        }
    },
    methods : {
        toUrl : function(url){
            Common.toUrl(url)
            return true
        }
    },
    mounted : function(){
		if ('-ms-scroll-limit' in document.documentElement.style 
            && '-ms-ime-align' in document.documentElement.style) {
            window.addEventListener('hashchange', () => {
                var currentPath = window.location.hash.slice(1)
                if (this.$route.path !== currentPath) {
                    this.$router.push(currentPath)
                }
            }, false)
        }
	},
    watch : {
        '$route': function(route) {
            if(route.path.indexOf('/news') >= 0){
                this.sNav = '资讯'
            }else if(route.path.indexOf('/download') >= 0){
                this.sNav = '下载'
            }else if(route.path.indexOf('/data') >= 0){
                this.sNav = '资料库'
            }else if(route.path.indexOf('/service') >= 0){
                this.sNav = '客服'
            }else{
                this.sNav = '首页'
            }
        }
    },
    created : function(){
        var url = window.location.href
        if(url.indexOf('/news') >= 0){
            this.sNav = '资讯'
        }else if(url.indexOf('/download') >= 0){
            this.sNav = '下载'
        }else if(url.indexOf('/data') >= 0){
            this.sNav = '资料库'
        }else if(url.indexOf('/service') >= 0){
            this.sNav = '客服'
        }else{
            this.sNav = '首页'
        }
    }
}
</script>
